﻿/// <reference path="AttachedHandler.js" />


function MouseEnterLeaveHandler(obj, type, handler, binding, args)
{
	this.AttachedHandler(obj, type, handler, binding, args);
}

MouseEnterLeaveHandler.Inherit(AttachedHandler);

if (____a)
{
	MouseEnterLeaveHandler.prototype = new AttachedHandler();
	MouseEnterLeaveHandler.prototype.AttachedHandler = new AttachedHandler();

}

MouseEnterLeaveHandler._Contains = function _Contains(container, child)
{
	while (child != null && child != container)
		child = child.parentNode;
	return (child == container);
}

MouseEnterLeaveHandler.prototype.get_AddType = function get_AddType()
{
	switch (this._type)
	{
		case "mouseenter": return "mouseover";
		case "mouseleave": return "mouseout";
	}
}

// FOR non-IE browsers, emulate MOUSEENTER and MOUSELEAVE (as opposed to MOUSEOVER and MOUSEOUT)
MouseEnterLeaveHandler.prototype._BindHandler = function _BindHandler(argument_list)
{
	var o = this._binding, f = AttachedHandler.ResolveHandler(this._handler), args = argument_list;
	if (o == null) o = this._obj;
	
	return function BoundHandler_MouseEnterLeave(e)
	{
		try
		{
			if (this === e.relatedTarget || MouseEnterLeaveHandler._Contains(this, e.relatedTarget)) // do nothing for children
				return;
		}
		catch (ex)
		{ // Firefox bug - relatedTarget could be the DIV.anonymous-div
			return;
		}
		var args2 = Events._GetArguments(arguments);

		return f.apply(o, args.concat(args2));
	};

}

